const app = getApp();
Page({
  data:{
    data:{},
    state:null,
    fromwhere:'',
    success1:{
      state:true,
      title:'提现成功',
      desc:'提现成功,请检查银行卡账户余额!',
      btn1:'返回首页',
      btn2:'查看账单'
    },
    success2: {
      state: true,
      title: '转账成功',
      desc: '转账成功,请检查账户余额!',
      btn1: '返回首页',
      btn2: '查看账单'
    },
    success3: {
      state: true,
      title: '打款成功',
      desc: '打款成功,请检查账户余额!',
      btn1: '返回首页',
      btn2: '查看账单'
    },
    error1:{
      state: false,
      title: '提现失败',
      desc: '提现失败,请检查银行卡信息是否正确!',
      btn1: '继续提现',
      btn2: '查看银行卡'
    },
    error2: {
      state: false,
      title: '转账失败',
      desc: '转账失败,请检查对方信息是否正确!',
      btn1: '继续转账',
      btn2: '返回首页'
    },
    error3: {
      state: false,
      title: '打款失败',
      desc: '打款失败,请检查对方信息是否正确!',
      btn1: '继续打款',
      btn2: '返回首页'
    }
  },
  onLoad:function(options){
    const that = this;
    console.log(options.state);
    that.state = options.state;
    if(options.state == "true"){
      if(options.from == 'transferme'){
        this.setData({
          data: this.data.success1,
          state: true,
          fromwhere:'transferme'
        })
      } else if (options.from == 'transferother') {
        this.setData({
          data: this.data.success2,
          state: true,
          fromwhere: 'transferother'
        })
      } else if (options.from == 'withdraw') {
        this.setData({
          data: this.data.success3,
          state: true,
          fromwhere: 'withdraw'
        })
      }
      // console.log(this.data.data);
      wx.setNavigationBarTitle({
        title: "成功"
      })
    }else{
      if (options.from == 'transferme') {
        this.setData({
          data: this.data.error1,
          state: false,
          fromwhere: 'transferme'
        })
      } else if (options.from == 'transferother') {
        this.setData({
          data: this.data.error2,
          state: false,
          fromwhere: 'transferother'
        })
      } else if (options.from == 'withdraw') {
        this.setData({
          data: this.data.error3,
          state: false,
          fromwhere: 'withdraw'
        })
      }
      // console.log(this.data.data);
      wx.setNavigationBarTitle({
        title: '失败'
      })
    }
  },
  btn1:function(){
    console.log(this.data.state);
    console.log(typeof this.data.state);
    console.log(this.data.fromwhere);
    if (this.data.state==true) {
      wx.switchTab({
        url: '../index/index',
      })
    }else{
      if (this.data.fromwhere == 'transferme'){
        wx.navigateTo({
          url: '../transferme/transferme',
        })
      } else if (this.data.fromwhere == 'transferother') {
        wx.navigateTo({
          url: '../transferother/transferother',
        })
      } else if (this.data.fromwhere == 'withdraw') {
        wx.navigateTo({
          url: '../withdraw/withdraw',
        })
      }
    }
  },
  btn2:function(){
    console.log(this.data.fromwhere);
    if (this.data.state==true) {
      wx.switchTab({
        url: '../bill/bill',
      })
    } else {
      if (this.data.fromwhere == 'transferme') {
        wx.navigateTo({
          url: '../my/bank/bank',
        })
      } else if (this.data.fromwhere == 'transferother') {
        wx.switchTab({
          url: '../index/index',
        })
      } else if (this.data.fromwhere == 'withdraw') {
        wx.switchTab({
          url: '../index/index',
        })
      }
    }
  }
})